/**
 * 
 */
package cn.ad.server.web.servlet.v2.parser;

import cn.ad.server.web.servlet.v2.requests.ClickRequest;
import cn.ad.server.web.servlet.v2.requests.TrackingRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * 点击请求解析类
 * @author Wu Chengjun
 *
 */
public class DefaultClickRequestParser extends TrackingRequestParser {
	
	/**
	 * 请求参数名--跳转目的地址
	 */
	public static final String PARAM_TARGET_URL = "target";
	
	
	/**
	 * 请求参数名-- 用户手指按下时的横坐标
	 */
	public static final String PARAM_DOWNX = "downx";
	
	/**
	 * 请求参数名--用户手指按下时的纵坐标
	 */
	public static final String PARAM_DOWNY = "downy";
	
	/**
	 * 请求参数名--用户手指离开手机屏幕时的横坐标
	 */
	public static final String PARAM_UPX = "upx";
	
	/**
	 * 请求参数名--用户手指离开手机屏幕时的纵坐标
	 */
	public static final String PARAM_UPY = "upy";
	
	
	/* (non-Javadoc)
	 * @see cn.falconnect.adserver.adapter.TrackingRequestParser#readTrackingParam(javax.servlet.http.HttpServletRequest, cn.falconnect.adserver.adapter.TrackingRequest)
	 */
	@Override
	public void readTrackingParam(HttpServletRequest request, TrackingRequest trackingRequest)  throws AdRequestParseException {
		super.readTrackingParam(request, trackingRequest);
		ClickRequest req = (ClickRequest)trackingRequest;
		req.setTarget(request.getParameter(PARAM_TARGET_URL));
		req.setDownx(request.getParameter(PARAM_DOWNX));
		req.setDownx(request.getParameter(PARAM_DOWNY));
		req.setDownx(request.getParameter(PARAM_UPX));
		req.setDownx(request.getParameter(PARAM_UPY));
	}

	/* (non-Javadoc)
	 * @see cn.falconnect.adserver.adapter.TrackingRequestParser#createTrackingRequest(javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public TrackingRequest createTrackingRequest(HttpServletRequest request) throws AdRequestParseException {
		return new ClickRequest();
	}
}
